package jp.shts.ohos.storyprogressbar.slice;

import jp.shts.ohos.storiesprogressview.PausableProgressBar;
import jp.shts.ohos.storiesprogressview.ResourceTable;

import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;

import ohos.agp.components.element.Element;
import ohos.app.Context;

import org.junit.Test;

import static org.junit.Assert.*;

/**
 * 单元测试
 */
public class MainAbilitySliceOhosTest extends AbilitySlice {
    /**
     * 测试获取颜色不为空
     */
    @Test
    public void getColorNotNull() {
        int res = ResourceTable.Color_progress_secondary;
        Context context = AbilityDelegatorRegistry.getAbilityDelegator().getAppContext();
        PausableProgressBar pausableProgressBar = new PausableProgressBar(context);
        int color = pausableProgressBar.getColor(context, res);
        assertNotEquals(0, color);
    }

    /**
     * 测试获取颜色不为空
     */
    @Test
    public void getColorNull() {
        int res = 0;
        Context context = AbilityDelegatorRegistry.getAbilityDelegator().getAppContext();
        PausableProgressBar pausableProgressBar = new PausableProgressBar(context);
        int color = pausableProgressBar.getColor(context, res);
        assertEquals(0, color);
    }

    /**
     * 测试获取Element不为空
     */
    @Test
    public void getColorDrawable() {
        int res = ResourceTable.Color_progress_secondary;
        Context context = AbilityDelegatorRegistry.getAbilityDelegator().getAppContext();
        PausableProgressBar pausableProgressBar = new PausableProgressBar(context);
        Element drawable = pausableProgressBar.getColorDrawable(context, res);
        assertNotNull(drawable);
    }

}